<!--
 * @Author: zhangfan
 * @Date: 2024-06-24 11:28:27
 * @LastEditors: ***
 * @LastEditTime: 2024-06-25 18:33:51
 * @Description: 子组件1
 * @FilePath: /demo/src/views/parent/components/child-one.vue
-->
<template>
  <div class="view-contain-one">
    <button @click="getParentData">获取父组件数据并调用其内部方法</button>
  </div>
</template>
<script>
export default {
  data () {
    return {
      message: 123
    }
  },
  methods: {
    getParentData () {
      const val = this.$parent.text
      const val1 = this.$parent.test()
      console.log('我是父组件中的text==', val)
      console.log('我是父组件中的test方法==', val1)
    }
  }
}
</script>
<style scoped>
.view-contain-one {
  height: 300px;
  width: 500px;
  border: 1px solid #ccc;
}
</style>
